var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var db = require('./model/db.js');
var cookieParser = require('cookie-parser')


//这些设定好之后post请求了就有了req.body了
app.use(bodyParser.urlencoded({ extended: false }))
app.use(bodyParser.json())

app.use(cookieParser())

app.set('view engine', 'ejs');
app.use(express.static('./public'))


app.get('/gl', function (req, res, next) {

    var mudidi = req.query.mudidi


    var mudidiarray = req.cookies.mudidi || [];      //读取cookie
    mudidiarray.push(mudidi);
    var aa= Array.from(new Set(mudidiarray))        //数组去重
    res.cookie('mudidi', aa, {})       //返回新的cookie
    res.send(req.cookies)
})

app.listen(3000)